﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace ConceptCorporateAdmin.Gui
{
    class NameService
    {
        private static List<int> ids_used = new List<int>();

        public static void setDocument(HtmlDocument document)
        {
            HtmlElementCollection collection = document.All;
            foreach (HtmlElement e in collection)
            {
                if (e.Id.IndexOf("_") != -1)
                {
                    string sid = e.Id.Substring(e.Id.IndexOf("_") + 1);
                    int id = int.Parse(sid);
                    ids_used.Add(id);
                }
            }
        }

        public static string addNextName()
        {
            string ret = "";
            for (int i = 0; i < 100000; i++)
            {
                if (ids_used.IndexOf(i) == -1)
                {
                    ret = "element_" + i;
                    ids_used.Add(i);
                    break;
                }
            }
            return ret;
        }
    
    }
}
